package com.you.concurrent.juc.condition;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;

public class ConditionWaitDemo {

    Lock lock;

    Condition condition;

    ConditionWaitDemo(Lock lock, Condition condition) {
        this.lock = lock;
        this.condition = condition;
    }

    public void conditionWaitMethod() {
        try {
            System.out.println("--------condition await start-------");
            lock.lock();
            condition.await();
            System.out.println("--------condition await end-------");
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }
    }
}
